package com.hello.booksale.service;

import com.hello.booksale.dao.BookDao;
import com.hello.booksale.entity.BookEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookService {
    @Resource
    private BookDao bookDao;

    public List<BookEntity> selectBook() {
        return bookDao.findAllBooks();
    }

    public List<BookEntity> selectBookByBookName(String bookName) {
        return bookDao.findBookByBookName(bookName);
    }

    public int selectCount() {
        return bookDao.selectCount();
    }

    public List<BookEntity> selectBookByPage(int pageBegin, int pageSize) {
        return bookDao.findBooksByPage(pageBegin, pageSize);
    }

    public void insertBook(BookEntity bookEntity) {
        bookDao.addBook(bookEntity);
    }

    public void updateBook(BookEntity bookEntity) {
        bookDao.updateBook(bookEntity);
    }
    public BookEntity selectBookById(int id){
        BookEntity bookEntity=bookDao.findBooksById(id);
        return bookEntity;
    }
    public void deleteBookById(int id) {
        bookDao.deleteBookById(id);
    }
}
